//package com.xiaoniu.mc;
//
//import com.netflix.hystrix.HystrixCommand;
//import com.netflix.hystrix.HystrixCommandGroupKey;
//import com.netflix.hystrix.HystrixCommandKey;
//import org.aspectj.lang.ProceedingJoinPoint;
//
///**
// * @类描述：
// * @创建人：林继丰
// * @创建时间：2017/9/15 17:45
// * @版权：Copyright (c) 深圳市牛鼎丰科技有限公司-版权所有.
// */
//public class HystrixCommandAdvice {
//    private String groupName;
//    private String commandName;
//
//    public Object runCommand(final ProceedingJoinPoint pjp) {
//        return wrapWithHystrixCommnad(pjp).execute();
//    }
//
//    private HystrixCommand<Object> wrapWithHystrixCommnad(final ProceedingJoinPoint pjp) {
//        return new HystrixCommand<Object>(setter()) {
//            @Override
//            protected Object run() throws Exception {
//                try {
//                    return pjp.proceed();
//                } catch (Throwable throwable) {
//                    throw (Exception) throwable;
//                }
//            }
//
//            @Override
//            protected Object getFallback() {
//                return null;
//            }
//        };
//    }
//
//    private HystrixCommand.Setter setter() {
//        return HystrixCommand.Setter
//                .withGroupKey(HystrixCommandGroupKey.Factory.asKey(groupName))
//                .andCommandKey(HystrixCommandKey.Factory.asKey(commandName));
//    }
//
//    public void setGroupName(String groupName) {
//        this.groupName = groupName;
//    }
//
//    public void setCommandName(String commandName) {
//        this.commandName = commandName;
//    }
//}
